<template>
  <el-container class="allbody" onscroll="false">

    <el-header style="height: 10.5%" class="headerbackgroud">
      <div style="color: white;font-size: 30px;text-align: center;margin-top: 20px;margin-left: 70px">典型工业设备和产品检测监测云服务平台</div>
      <el-card style="width:150px;height:50px;text-align:left;margin-left:80px;margin-top:-30px;border-radius:30px;background-color: #7d93ea">
        <div style="color: white;margin-left: 6px;margin-top: -10px">
          中国特种设备检测研究院
        </div>
      </el-card>
      <el-card style="width:127px;height:60px;align-items:right;margin-left:1600px;margin-top:-30px;border-radius:30px;background-color: #7d93ea">
        <div style="color: white;margin-left: 2px;margin-top: -8px">
          {{dateFormat(date)}}
        </div>
      </el-card>
      <el-card style="width:150px;height:50px;align-items:right;margin-left:1400px;margin-top:-60px;border-radius:30px;background-color: #7d93ea">
        <div style="color: white;margin-left: 2px;margin-top: -8px">
          点检数据统计
        </div>
      </el-card>
    </el-header>



    <el-main style="height: 100%; z-index: 5">
      <el-row style="width: 100%;height: 10%">
      <el-button style="color: #009bfe" @click="Mainlift">主起升</el-button>
      <el-button style="color: #009bfe" @click="Auxiliarylift">副起升</el-button>
      <el-button style="color: #009bfe" @click="MainTrolley">主小车</el-button>
      <el-button style="color: #009bfe" @click="AuxiliaryTrolley">副小车</el-button>
      <el-button style="color: #009bfe" @click="Cart">大车</el-button>
      </el-row>
      <el-row class="rowclass">
        <el-col style="width: 40%;height: 100%"><bar-chart2 :PositionXdata = "PositionXdata":PositionYdata = "PositionYdata" :type="type" :typenumber="typenumber" :typeXrotate="typeXrotate"  :typeXbarwidth="typeXbarwidth" :key="timer"></bar-chart2></el-col>
      </el-row>
      <el-row class="rowclass">
        <el-col style="width: 40%;height: 100%"><bar-chart :FullyearYdata = "FullyearYdata" :type="type" :typenumber="typenumber" :key="timer"></bar-chart></el-col>
      </el-row>
    </el-main>
    <div class="map1"><img src="../../../../assets/image/lbx.png"></div>
    <div class="map2"><img src="../../../../assets/image/jt.png"></div>
    <div class="map3"><img src="../../../../assets/image/map.png"></div>
  </el-container>
</template>

<script>
  import ElContainer from "element-ui/packages/container/src/main"
  import ElAside from "element-ui/packages/aside/src/main"
  import ElHeader from "element-ui/packages/header/src/main"
  import ElMain from "element-ui/packages/main/src/main"

  import BarChart from './components/BarChart'
  import BarChart2 from './components/BarChart2'


  import { get, get as userType, del, dels } from '@/api/sys/connSysAuthApi'
  import { parseTime } from '@/utils'
  import { req } from '@/api/base/BaseApi'


  export default {
    name: 'index',
    components: { BarChart2, BarChart },
    comments: {
      ElMain,
      ElHeader,
      ElAside,
      ElContainer,
      BarChart,
      BarChart2
    },
    methods: {
      dateFormat(time) {
        var date = new Date(time)
        var year=date.getFullYear()
        /* 在日期格式中，月份是从0开始的，因此要加0
         * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
         * */
        var month= date.getMonth()+1<10 ? "0"+(date.getMonth()+1) : date.getMonth()+1
        var day=date.getDate()<10 ? "0"+date.getDate() : date.getDate()
        var hours=date.getHours()<10 ? "0"+date.getHours() : date.getHours()
        var minutes=date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes()
        var seconds=date.getSeconds()<10 ? "0"+date.getSeconds() : date.getSeconds()
        // 拼接
        return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds
      },
      tableRowStyle({ row, rowIndex }) {
        return 'background-color: #02152f;color: #fff'
      },
      tableHeaderColor({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          return 'background-color: #2ec7c9;color: #fff;font-weight: 500;'
        }
      },
      handleSetLineChartData(type) {
        this.lineChartData = lineChartData[type]
      },
      getRowClass({ row, column, rowIndex, columnIndex }) {
        return 'background:#06134A;color:#fff;'
      },
      Mainlift() {
        this.typenumber = '0'
        this.timer = new Date().getTime()
      },
      Auxiliarylift() {
        this.typenumber = '1'
        this.timer = new Date().getTime()
      },
      MainTrolley() {
        this.typenumber = '2'
        this.timer = new Date().getTime()
      },
      AuxiliaryTrolley() {
        this.typenumber = '3'
        this.timer = new Date().getTime()
      },
      Cart() {
        this.typenumber = '4'
        this.timer = new Date().getTime()
      }
    },

    data() {
      return {
        date: new Date(),
        PositionXdata: [
          ['地脚螺丝', '箱体及传动轴', '啮合及润滑', '制动轮及闸架、闸皮', '联接螺栓', '十字头及轴承', '滑轮及轴承', '钢丝绳卡及平衡臂', '动滑轮组滑轮及轴承', '横梁及吊叉', '板钩衬板及轴销、端部卡板', '联轴器及轴承', '卷筒及钢丝绳压板', '磨损与断丝', '排列、润滑及变形', '底座螺栓', '制动间距、摩擦片磨损', '液压站'],
          ['地脚螺栓', '箱体及传动轴', '啮合及润滑', '制动轮及闸架、闸皮', '联接螺栓', '滑轮及轴承', '动滑轮组滑轮及轴承', '钩头', '钩头横梁及护罩', '联轴器及轴承', '卷筒及钢丝绳压板', '磨损与断丝', '排列、润滑及变形'],
          ['地脚螺丝', '箱体及传动轴', '啮合及润滑', '制动轮及闸架、闸皮', '联接螺栓', '轮缘及轴承', '无变形、连接牢固'],
          ['地脚螺丝', '箱体及传动轴', '啮合及润滑', '制动轮及闸架、闸皮', '联接螺栓', '轮缘及轴承', '无变形、连接牢固'],
          ['地脚螺丝', '箱体及传动轴', '啮合及润滑', '制动轮及闸架、闸皮', '联接螺栓', '十字头及轴卡', '轮缘及轴承', '无变形、连接牢固']],
        PositionYdata: [
          [0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 6, 0, 0, 4, 1, 3, 1, 1],
          [0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 1, 8, 0, 1, 0, 1],
          [0, 0, 0, 0, 0, 0, 0],
          [1, 0, 5, 0, 2, 0, 4, 0]],
        FullyearYdata: [
          [4, 5, 3, 1, 0, 0, 0, 1, 4, 3, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
          [0, 0, 1, 1, 1, 2, 4, 0, 0, 0, 0, 1],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 1, 0, 3, 1, 1, 0, 0, 2, 2, 1, 1]],
        type: ['主起升', '副起升', '主小车', '副小车', '大车'],
        typenumber: '0',
        typeXrotate: [20, 10, 0, 0, 0],
        typeXbarwidth: [20, 20, 80, 80, 80],
        timer: ''
      }
    },
    filters: {
      userTypeFilter(type) {
        let typeText = type
        userTypes.forEach((val) => {
          if (type === val.value) {
            typeText = val.name
          }
        })
        return typeText
      },
      menuFilter(ids) {
        let length = 0
        if (ids) {
          length = ids.length
        }
        return length
      },
      dateTimeFilter(time) {
        return parseTime(time)
      }
    },
    mounted() {
      let _this = this //声明一个变量指向vue实例this,保证作用域一致
      this.timer = setInterval(function() {
        _this.date = new Date()//修改数据date
      }, 1000),
        console.log(this.$route.path)    // 输出当前页面的路由，如：/home
    }
  }

</script>

<style lang="less" scoped>
  .headerbackgroud{
    background-image: url("../../../../assets/screen-header.jpg");
  }
  .allbody{
    width:1850px;
    height:1050px;
    background-image: url("../../../../assets/bg.jpg");

  }
  .rowclass{
    width: 100%;
    height: 45%;
  }
  #text{
    -webkit-text-fill-color:white
  ;
  }
  .select{
    color: white;
  }
  .hello{
    // 未选中任何选项的时候 placeholder的样式 需要先选中父元素 增加权重
    /deep/ input::-webkit-input-placeholder {
      color: #fff;
    }
    /deep/  input::-moz-input-placeholder {
      color: #fff;
    }
    /deep/  input::-ms-input-placeholder {
      color: #fff;
    }

    //修改的是el-input的样式
    //一种方法是设置最里层el-input__inner的背景色 外层的两级父元素设置为透明色
    //另一种方法是从el-select到el-input__inenr的背景色都设置为需要的颜色
    /deep/ .el-select,
    /deep/ .el-input,
    /deep/ .el-input__inner{
      background-color:#08164D ;
      color:#fff;
      border:0px;
      border-radius:0px;
      text-align: center;
    }
  }
  .map1,.map2, .map3{ position:absolute; opacity: .5}
  .map1{ margin-left:580px;margin-top:230px;z-index: 2;  animation: myfirst2 15s infinite linear;}
  .map2{ margin-left:625px;margin-top:275px;z-index: 3; opacity: 0.2; animation: myfirst 10s infinite linear;}
  .map3{ margin-left:650px;margin-top:300px;z-index: 1;}
  @keyframes myfirst2
  {
    from {transform: rotate(0deg);}
    to {transform: rotate(359deg);}
  }

  @keyframes myfirst
  {
    from {transform: rotate(0deg);}
    to {transform: rotate(-359deg);}
  }
</style>
